package com.example.concurrent.chapter09;

/**
 * @author Create By Liuqz
 * @date 2018/11/23 10:56
 */
public class Singleton {

    private static int x = 0;

    private static int y;

    private static Singleton instance = new Singleton();

    private Singleton() {
        x++;
        y++;
    }


    public static Singleton getInstance() {
        return instance;
    }

    /**
     * result : singleton.x = 1
     *          singleton.y = 1
     * @param args
     */
    public static void main(String[] args) {
        Singleton singleton = Singleton.getInstance();
        System.out.println(singleton.x);
        System.out.println(singleton.y);
    }
}
